<?php
	$tid = trim($_POST['tid']);
	$tName = trim($_POST['tName']);
	$left = trim($_POST['left']);
	$search_type = trim($_POST['search_type']);
	if(!$tid || !$left){
		exit('parm is miss !');
	}
	require '../autoload.php';
	$mp = new MyPdo();

	$sql = "select lefts,rights from translate_info where typeid=? and {$search_type} like '%' ? '%'";
	$arr = array($tid,$left);

	//echo $sql;exit;
	$res = $mp->dql($sql,$arr);
	if($res){
		if($search_type == 'lefts'){
			$dir = '../Runtime/CacheLeftVague/'.$tName;
		}else{
			$dir = '../Runtime/CacheRightVague/'.$tName;
		}
		$fileName = $dir.'/'.md5($left);
		if(!is_dir($dir)){
			mkdir($dir,0777,true);
		}
		ob_start();
		echo json_encode($res);
		$res2 = ob_get_contents();
		file_put_contents($fileName, $res2);
	}else{
		echo 'err';
	}
